<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Route::get('/', function () {
//     return view('welcome');
// });

Route::get('/test', 'LaravelController@test'); // 首页

// 前端
Route::get('/', 'LaravelController@index'); // 首页
Route::get('/cat/{id_or_slug}.html', 'LaravelController@cat'); // 分类页
Route::get('/tag/{id_or_slug}.html', 'LaravelController@tag'); // 标签页
Route::get('/search/{keywords}', 'LaravelController@search'); // 搜索页
Route::get('/article/{id_or_slug}.html', 'LaravelController@article'); // 文章页

// 登录
Route::get('/admins/account/login', 'admins\Account@login')->name('login');
Route::get('/admins/account/vericode', 'admins\Account@vericode');
Route::post('/admins/account/dologin', 'admins\Account@dologin');
Route::get('/admins/account/logout', 'admins\Account@logout');

// 后台分组路由
Route::namespace('admins')->middleware(['auth', 'rights'])->group(function () {
    // 后台
    Route::get('/admins/home/index', 'Home@index');
    Route::get('/admins/home/welcome', 'Home@welcome');

    // 管理员
    Route::get('/admins/admin/index', 'Admin@index');
    Route::get('/admins/admin/add', 'Admin@add');
    Route::post('/admins/admin/save', 'Admin@save');
    Route::get('/admins/admin/edit', 'Admin@edit');
    Route::post('/admins/admin/save_edit', 'Admin@save_edit');
    Route::get('/admins/admin/del', 'Admin@del');
    // 清理各种缓存
    Route::get('/admins/admin/clear', 'Admin@clear');

    // 菜单
    Route::get('/admins/menus/index', 'Menus@index');
    Route::get('/admins/menus/add', 'Menus@add');
    Route::post('/admins/menus/save', 'Menus@save');
    Route::get('/admins/menus/edit', 'Menus@edit');
    Route::post('/admins/menus/save_edit', 'Menus@save_edit');
    Route::get('/admins/menus/del', 'Menus@del');

    // 角色权限
    Route::get('/admins/groups/index', 'Groups@index');
    Route::get('/admins/groups/add', 'Groups@add');
    Route::post('/admins/groups/save', 'Groups@save');
    Route::get('/admins/groups/edit', 'Groups@edit');
    Route::post('/admins/groups/save_edit', 'Groups@save_edit');
    Route::get('/admins/groups/del', 'Groups@del');

    // 设置
    Route::get('/admins/setting/index', 'Setting@index');
    Route::post('/admins/setting/save', 'Setting@save');

    // 文章管理
    Route::get('/admins/article/index', 'Article@index');
    Route::get('/admins/article/add', 'Article@add');
    Route::post('/admins/article/save', 'Article@save');
    Route::get('/admins/article/edit', 'Article@edit');
    Route::post('/admins/article/save_edit', 'Article@save_edit');
    Route::get('/admins/article/del', 'Article@del');

    // 分类管理
    Route::get('/admins/cat/index', 'Cat@index');
    Route::get('/admins/cat/add', 'Cat@add');
    Route::post('/admins/cat/save', 'Cat@save');
    Route::get('/admins/cat/edit', 'Cat@edit');
    Route::post('/admins/cat/save_edit', 'Cat@save_edit');
    Route::get('/admins/cat/del', 'Cat@del');

    // 标签管理
    Route::get('/admins/tag/index', 'Tag@index');
    Route::get('/admins/tag/add', 'Tag@add');
    Route::post('/admins/tag/save', 'Tag@save');
    Route::get('/admins/tag/edit', 'Tag@edit');
    Route::post('/admins/tag/save_edit', 'Tag@save_edit');
    Route::get('/admins/tag/del', 'Tag@del');

    // 回收站
    Route::get('/admins/trash/index', 'Trash@index');
    Route::get('/admins/trash/restore', 'Trash@restore');
    Route::get('/admins/trash/del', 'Trash@del');

    // 文件和上传
    Route::get('/admins/files/index', 'Files@index');
    Route::get('/admins/files/add', 'Files@add');
    Route::get('/admins/files/calc', 'Files@calc');
    Route::get('/admins/files/edit', 'Files@edit');
    Route::post('/admins/files/save_edit', 'Files@save_edit');
    Route::get('/admins/files/del', 'Files@del');
    Route::post('/admins/files/uploads', 'Files@uploads');

    // 评论
    Route::get('/admins/comment/index', 'Comment@index');
    Route::get('/admins/comment/edit', 'Comment@edit');
    Route::post('/admins/comment/save_edit', 'Comment@save_edit');
    Route::get('/admins/comment/del', 'Comment@del');
    Route::get('/admins/comment/pending', 'Comment@pending'); //批量待审核
    Route::get('/admins/comment/spam', 'Comment@spam'); //批量垃圾评论
    Route::get('/admins/comment/passed', 'Comment@passed'); //批量审核通过
});

// 评论发布
Route::get('/admins/comment/add', 'admins\Comment@add');
Route::post('/admins/comment/save', 'admins\Comment@save');





// CheckLogin
// Route::get('/login', function () {
//     return 'login page';
// });

// CheckNameMiddleWare
// Route::get('/home/{name}', function ($name) {
//     return 'Welcome: ' . $name;
// })->middleware('checkname');

// 注册资源路由
// Route::resource('/staffs', 'StaffsController');

// Display a listing of the resource.
// Route::get('/staffs', 'StaffsController@index')
//     ->name('staffs.index');

// Show the form for creating a new resource.
// Route::get('/staffs/create', 'StaffsController@create')
//     ->name('staffs.create');

// Store a newly created resource in storage.
// Route::post('/staffs/store', 'StaffsController@store')
//     ->name('staffs.store');

// Display the specified resource.
// Route::get('/staffs/{id}/show', 'StaffsController@show')
//     ->where(['id' => '\d+'])
//     ->name('staffs.show');

// Show the form for editing the specified resource.
// Route::get('/staffs/{id}/edit', 'StaffsController@edit')
//     ->where(['id' => '\d+'])
//     ->name('staffs.edit');

// Update the specified resource in storage.
// Route::put('/staffs/{id}/update', 'StaffsController@update')
//     ->where(['id' => '\d+'])
//     ->name('staffs.update');

// Remove the specified resource from storage.
// Route::delete('/staffs/{id}/destroy', 'StaffsController@destroy')
//     ->where(['id' => '\d+'])
//     ->name('staffs.destroy');
